﻿using LibraryManagement.DataAccess;
using LibraryManagement.Domain;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace LibraryManagement.UI.Employee.Dialogs
{
    /// <summary>
    /// Interaction logic for SaveNewBookDialog.xaml
    /// </summary>
    public partial class SaveNewBookDialog : DevExpress.Xpf.Core.DXWindow
    {
        private AppDbContext _context;
        public SaveNewBookDialog()
        {
            InitializeComponent();
            _context = new AppDbContext();
        }

        private void DXWindow_Loaded(object sender, RoutedEventArgs e)
        {

            this.AddBookStatus();
       
            this.AddPublishers();
        }

        private void AddBookStatus()
        {
            foreach (var item in Enum.GetNames(typeof(BookStatus)))
            {
                this.InitialStatus.Items.Add(item);
            }
        }

        private void AddPublishers()
        {
            
            foreach(var item in this._context.Publishers.Take(30))
            {
                this.Publisher.Items.Add(item);
            }
        }

        private void AuthorSelectionStart_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            var authorWindow = new AuthorSelectionDialog() { Owner = this };
            authorWindow.WindowStartupLocation = System.Windows.WindowStartupLocation.Manual;
            authorWindow.Left = SystemParameters.WorkArea.Width - authorWindow.Width ;
            authorWindow.Show();
        }
    }
}
